from constants import *
class SortMaster(object):
    def __init__( self ):
        self.sortattr = None

    def __cmp__( self, other ):
        if other == None:
            return 1
        sortattr = self.sortattr
        selfvalue  = getattr( self, sortattr)
        othervalue = getattr(other, sortattr)
        if selfvalue > othervalue:
            return 1
        elif selfvalue < othervalue:
            return -1
        elif abs(selfvalue - othervalue) < TOL:
            return 0

